import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
//chunk 片段：一个或者多个模块打包的集合
//路由懒加载，路由组件一定会被打包成一个chunk
//修改路由chunk名字的方式  component: () => import(/* webpackChunkName :'home' */ '@/views/Home')
//作业：合并路由组件，减少网络请求
const routes = [
  {
    path: '/',
    component: () => import('@/views/layout'),
    redirect: '/ ',
    children: [
      {
        path: '/ ',
        component: () => import('@/views/Home')
      },
      {
        path: '/video',
        component: () => import(/* webpackChunkName : "base" */ '@/views/Video')
      },
      {
        path: '/qa',
        component: () => import(/* webpackChunkName : "base" */ '@/views/QA')
      },
      {
        path: '/profile',
        component: () => import('@/views/My')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login')
  },
  {
    path: '/search',
    component: () => import('@/views/search')
  },
  {
    path: '/user',
    component: () => import('@/views/User')
  }
]

const router = new VueRouter({
  routes
})

export default router
